package com.jt.demo2.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Order(value = 1)
public class Aspect2 {
    @Pointcut("@annotation(com.jt.demo2.aop.TX)")
    public void pointCut(){
    }

    @Around("@annotation(com.jt.demo2.aop.TX)")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        long l = System.nanoTime();
        System.out.println("环绕通知开始前1");
        Object result = joinPoint.proceed();
        System.out.println("环绕通知结束后1");
        long l1 = System.nanoTime();
        System.out.println(l1-l);
        return result;
    }
}
